package org.example.springboot.service;

import org.example.springboot.entity.ExpertAppointment;
import org.example.springboot.repository.ExpertAppointmentRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

@Service
public class ExpertAppointmentService {
    @Autowired
    private ExpertAppointmentRepository expertAppointmentRepository;

    public List<ExpertAppointment> findByExpertId(Long expertId) {
        return expertAppointmentRepository.findByExpertId(expertId);
    }

    public List<ExpertAppointment> findByUserId(Long userId) {
        return expertAppointmentRepository.findByUserId(userId);
    }

    public ExpertAppointment save(ExpertAppointment appointment) {
        return expertAppointmentRepository.save(appointment);
    }

    public ExpertAppointment findById(Long id) {
        return expertAppointmentRepository.findById(id).orElse(null);
    }

    public void delete(Long id) {
        expertAppointmentRepository.deleteById(id);
    }
} 